import WorkerMSDB
import sys
import pdb

reader = WorkerMSDB.Worker('192.168.4.5', '50359', 'transferTest', 'sa', 'ms-004')
reader.connect()
c = reader.connection.cursor()
query = 'SELECT TOP (100) id,deviceId,eventId,eventTime,rs232str,SaveTime FROM _rs232_data WHERE deviceId=2435'
#query = 'SELECT TOP (2) eventTime,contactData FROM _contactId_data_internal WHERE deviceId=17 order by eventtime desc'
c.execute(query)
d = c.fetchall()
#for s in d: print s
#pdb.set_trace()
j = 0
for e in d:
#        for i in e[4]: sys.stdout.write('%s ' % i)
#        buf = e[4]
#        sys.stdout.write('%d: ' % j)
        for i in e[4]: sys.stdout.write('%s ' % (str(hex(ord(i)))))
        j += 1
#	print e[1].encode('hex_codec')
#	for i in e[4]: sys.stdout.write('%s' % (i.decode('cp866')))
#	sys.stdout.write('\n')
        sys.stdout.write('\n')
	
